<template>
  <div>
    <el-table :data="specsList" border style="width: 100%">
      <el-table-column prop="specsname" label="属性名称" width="180">
      </el-table-column>
      <el-table-column prop="username" label="属性值" width="180">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="primary"
            plain
            v-for="(item, index) in scope.row.attrs"
            :key="index"
            >{{ item }}</el-button
          >
        </template>
      </el-table-column>
      <el-table-column prop="status" label="状态" width="180">
        <template slot-scope="scope">
          <el-button
            plain
            :type="scope.row.status == 1 ? 'success' : 'warning'"
            size="mini"
            >{{ scope.row.status == 1 ? "启用" : "禁用" }}</el-button
          >
        </template>
      </el-table-column>
      <el-table-column prop="" label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
            >编辑</el-button
          >
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  props: ["specsList"],
  data() {
    return {
      cellStyle: { background: "#FF6040", color: "white", height: "50px" },
    };
  },
  mounted() {},
  methods: {
    handleEdit(index, row) {
      // 通知父亲修改数据（子传父）==>form修改数据（父传子）
      // this.$emit('edit', { index: index, row: row })

      // 兄弟通信
      this.$BUS.$emit("edit", { index, row });
    },
    handleDelete(index, row) {
      // 通知父亲修改数据（子传父）
      this.$emit("remove", { index, row });
    },
  },
};
</script>

<style scoped>
</style>
